﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Wy.JiZhangSoft.Filters
{
    public class ApiResultFilter : IAsyncActionFilter
    {
        public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            ActionExecutedContext executedContext = await next.Invoke();
            // 异常处理交给全局异常过滤器
            if (executedContext.Exception != null)
            {
                return;
            }


            //var httpResult = new ResultModel<object>
            //{
            //    Data = result?.Value,
            //    Successed = true
            //};
            //var result = new ObjectResult(httpResult)
            //{
            //};
            //executedContext.Result = result;
        }
    }
}
